<template>
  <div class="createoper-step">
    <div class="xh-type-name">
      <span class="title">历史数据</span>
    </div>

    <div class="createoper-step-3-body">
      <el-table
        height="60vh"
        :cell-class-name="tableRowClassName"
        header-cell-class-name="createoper-step-table-header"
        border
        :data="formData.list"
        style="width: 100%"
      >
        <el-table-column prop="name" label="科目"> </el-table-column>
        <el-table-column prop="year" label="年份">
          <template slot-scope="{ row }">
            <el-input
              size="small"
              class="x-table-input"
              v-model="row.year"
              placeholder="请输入"
            ></el-input>
          </template>
        </el-table-column>
        <el-table-column prop="value" label="数值">
          <template slot-scope="{ row }">
            <el-input
              size="small"
              class="x-table-input"
              v-model="row.value"
              placeholder="请输入"
            ></el-input>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
export default {
  name: "Step3",
  props: {
    data: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {};
  },
  watch: {},
  computed: {
    formData: {
      get() {
        console.log(this.data);
        return (
          this.data || {
            list: [],
          }
        );
      },
      set(val) {
        this.$emit("update:data", val);
      },
    },
  },
  mounted() {},
  methods: {
    tableRowClassName(data) {

      const { row, rowIndex, columnIndex } = data;

      if (columnIndex === 0) {
        return "createoper-step-warning-row";
      }
      return "";
    },
  },
};
</script>
<style lang="scss" scoped>
.createoper-step-3-body {
  margin-top: 20px;
}
.createoper-step-3-body ::v-deep {
  .createoper-step-3-table-header {
    background-color: rgba(243, 245, 246, 1);
  }
  .warning-row {
    background-color: rgba(238, 246, 252, 1);
  }
}
</style>
